import { createApp } from 'vue'
import App from './App.vue'
import router from '@/router/index.js'
import pinia from './stores'
import {
  Button,
  Field,
  CellGroup,
  Tabbar,
  TabbarItem,
  DropdownMenu,
  DropdownItem,
  NavBar,
  Col,
  Row,
  Progress,
  Checkbox,
  CheckboxGroup,
  Switch,
  Icon,
  ActionSheet,
  Popup,
  Dialog,
  PullRefresh,
  Calendar,
  Pagination,
  Image as VanImage,
} from 'vant'

import 'vant/lib/index.css'
import 'amfe-flexible'
import '@/assets/iconfont.css'
import './permission'

const app = createApp(App)
app.use(Button)
app.use(Field)
app.use(CellGroup)
app.use(Tabbar)
app.use(TabbarItem)
app.use(DropdownMenu)
app.use(DropdownItem)
app.use(NavBar)
app.use(Col)
app.use(Row)
app.use(Progress)
app.use(Checkbox)
app.use(CheckboxGroup)
app.use(Switch)
app.use(Icon)
app.use(ActionSheet)
app.use(Popup)
app.use(Dialog)
app.use(PullRefresh)
app.use(Calendar)
app.use(Pagination)
app.use(VanImage)

import My_Tabbar from '@/components/Tabbar.vue'
import Nav_bar from '@/components/Nav_bar.vue'
import Select_down from '@/components/Select_down.vue'
import Table from '@/components/Table.vue'
import T_map from '@/components/T_map.vue'
import Data_presentation_box from '@/components/Data_presentation_box.vue'
import Null_data from '@/components/Null_data.vue'
import Machine_item from '@/components/Machine_item.vue'
import My_Pagination from '@/components/Pagination.vue'

app.component('Tabbar', My_Tabbar)
app.component('Nav_bar', Nav_bar)
app.component('Select_down', Select_down)
app.component('Table', Table)
app.component('T_map', T_map)
app.component('Data_presentation_box', Data_presentation_box)
app.component('Null_data', Null_data)
app.component('Pagination', My_Pagination)
app.component('Machine_item', Machine_item)

app.use(router)
app.use(pinia)
app.mount('#app')

//根据版本号清空用户缓存
import { version } from '../package.json'
const VUE_APP_VERSION = version
const vers = window.localStorage.getItem('Version')
if (VUE_APP_VERSION != vers) {
  localStorage.clear()
  sessionStorage.clear()
  window.localStorage.setItem('Version', VUE_APP_VERSION)
  location.reload()
}
